package com.kaifamiao.www.demo.do0812;

import java.util.Iterator;
import java.util.Vector;

public class Test {
    public static void main(String[] args) {

        Vector vector = new Vector();
        for (int i = 0;i<100;i++){
            vector.add(""+i);
        }
        System.out.println(vector.capacity());
        System.out.println(vector.size());
        //集合不建议在 for循环中删除元素，不要在遍利中使用修改集合的操作（add remove）
        Iterator iterator = vector.iterator();
        int count = 0;
        while (iterator.hasNext()){
            iterator.next();//获取下一个元素
            iterator.remove();
            if (++count >=99){
                break;
            }
        }
        System.out.println(vector.capacity());
        System.out.println(vector.size());
    }
}
